import React from 'react'
import { Table,Input,Button} from 'antd';
import axios from '../service.js'
class Reaccount extends React.Component {
      constructor(props){
        super(props);
        this.state = { cardcode:"",alldata:[]};
        this.columns = [
          {
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
            width: 100,
            fixed: 'left',
          },
          {
            title: '班级',
            dataIndex: 'grade',
            key: 'grade',
            width: 100,
          },
          {
            title: '性别',
            dataIndex: 'sex',
            key: 'sex',
            width: 100,
          },
          {
            title: '生日',
            dataIndex: 'birthday',
            key: 'birthday',
            width: 100,
          },
          {
            title: '证件类型',
            dataIndex: 'cardtype',
            key: 'cardtype',
          },
          {
            title: '证件号码',
            dataIndex: 'cardcode',
            key: 'cardcode',
          },
          {
            title: '国籍',
            dataIndex: 'nationality',
            key: 'nationality',
          },{
            title: '民族',
            dataIndex: 'nation',
            key: 'nation',
          },{
            title: '海外',
            dataIndex: 'oversea',
            key: 'oversea',
          },{
            title: '籍贯',
            dataIndex: 'nativeplace',
            key: 'nativeplace',
          },{
            title: '当前住址',
            dataIndex: 'curplace',
            key: 'curplace',
          },{
            title: '入学日期',
            dataIndex: 'indate',
            key: 'indate',
          },{
            title: '就读方式',
            dataIndex: 'readtype',
            key: 'readtype',
          },{
            title: '独生子女',
            dataIndex: 'only',
            key: 'only',
          },{
            title: "留守儿童",
            dataIndex: 'staybehind',
            key: 'staybehind',
          },{
            title: '随迁子女',
            dataIndex: 'followup',
            key: 'followup',
          },{
            title: '健康情况',
            dataIndex: 'health',
            key: 'health',
          },{
            title: '是否残疾',
            dataIndex: 'disable',
            key: 'disable',
          },{
            title: '残疾类别',
            dataIndex: 'disabletype',
            key: 'disabletype',
          },{
            title: '是否孤儿',
            dataIndex: 'orphan',
            key: 'orphan',
          },{
            title: '监护人姓名',
            dataIndex: 'cusname',
            key: 'cusname',
          },{
            title: '监护人关系',
            dataIndex: 'cusrelation',
            key: 'cusrelation',
          },{
            title: '监护人证件类型',
            dataIndex: 'cuscardtype',
            key: 'cuscardtype',
          },{
            title: '监护人证件号码',
            dataIndex: 'cuscardcode',
            key: 'cuscardcode',
          },{
            title: '区域',
            dataIndex: 'region',
            key: 'region',
          },{
            title: '机构',
            dataIndex: 'branch',
            key: 'branch',
            fixed: 'right',
          }
        
        
        ];
          
      }
      componentDidMount(){
        this.init();
      }
      init=()=>{
           let _this=this;
           axios.post('/query/info',{cardcode:_this.state.cardcode}).then((response)=>{
               let data=response.data;
               let dataArr=[];
               for(let i in data){
                    dataArr.push({
                        key:i,
                        name:data[i]['name'],
                        grade:data[i]['grade'],
                        sex:data[i]['sex'],
                        birthday:data[i]['birthday'],
                        cardtype:data[i]['cardtype'],
                        cardcode:data[i]['cardcode'],
                        nationality:data[i]['nationality'],
                        nation:data[i]['nation'],
                        oversea:data[i]['oversea'],
                        nativeplace:data[i]['nativeplace'],
                        curplace:data[i]['curplace'],
                        indate:data[i]['indate'],
                        readtype:data[i]['readtype'],
                        only:data[i]['only'],
                        staybehind:data[i]['staybehind'],
                        followup:data[i]['followup'],
                        health:data[i]['health'],
                        disable:data[i]['disable'],
                        disabletype:data[i]['disabletype'],
                        orphan:data[i]['orphan'],
                        cusname:data[i]['cusname'],
                        cusrelation:data[i]['cusrelation'],
                        cuscardtype:data[i]['cuscardtype'],
                        cuscardcode:data[i]['cuscardcode'],
                        branch:data[i]['branch'],
                        region:data[i]['region']
                    })
                    
               }
               console.log(dataArr);
               _this.setState({alldata:dataArr});
               //console.log(this.state.alldata)
           })
           
      }
      query=()=>{
          this.init();
      }
      changevalue=(e)=>{
          let cardcode=e.target.value;
          this.setState({cardcode:cardcode});
      }
      render(){
        return (
           <div>
             <div style={{float:"right"}}>
                <Input id="queryinput" autoComplete="off" allowClear={true}  placeholder="请输入学生身份证号" onChange={event => this.changevalue(event)} onPressEnter={this.query}  style={{width:"200px",marginRight:"10px"}}/>
                <Button onClick={this.query}>查询</Button>
              </div>
              <Table style={{paddingTop:50}} columns={this.columns} scroll={{ x: 2600 }} dataSource={this.state.alldata} pagination={{ pageSize: 5 }} />
           </div>
        )
      }
}
export default Reaccount;